using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Ent.Voice.Nomination;
using Ent.Web.Helper;
using Ent.Web.WebControl;
public partial class Controls_EntryView : System.Web.UI.UserControl
{
    private Entry _entry;
    public Entry View
    {
        get { return _entry; }
        set { _entry = value; }
    }
    private FontUnit _userFontSize = FontUnit.Parse("10px");
    public FontUnit UserFontSize
    {
        get { return _userFontSize; }
        set { _userFontSize = value; }
    }
    private int _userMaxChar = 15;
    public int UserMaxChar
    {
        get { return _userMaxChar; }
        set { _userMaxChar = value; }
    }
    private int _pageIndex = 1;
    public int PageIndex
    {
        get { return _pageIndex; }
        set { _pageIndex = value; }
    }
    private OrderBy _orderby = OrderBy.None;
    public OrderBy OrderBy
    {
        get { return _orderby; }
        set { _orderby = value; }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        ShowEntry();
        if (!IsPostBack)
            SetJavascript();
    }
    void ShowEntry()
    {
        DashEntry de = new DashEntry();
        de.ShowMedia = true; ;
        de.FileWidth = 400;
        de.FileHeight = 240;
        de.EntryMaxChar = -1;
        de.ShowControls = true;
        de.AllowMaximize = true;
        de.ShowComments = true;
        de.AutoStart = false;
        de.ShowThumb = false;
        cEntries.PageIndex = _pageIndex;
        cEntries.OrderBy = _orderby;
        if (View != null)
        {
            cFeed.EntryId = View.Id;
            cFeed.EntryName = View.Title;
            lblUpload.Text = FileHelper.GetUploadString(View, de, Server.MapPath("~"), ConfigurationManager.AppSettings["BaseUrl"], ResourceHelper.Get("LBL_Comments"));
            cEntryStats.Entry = View;
            cEntries.Id = View.EventId.ToString();
            cEntries.HeaderText = Common.GetImageTextLink(ConfigurationManager.AppSettings["BaseUrl"] + "/ShowEvent.aspx?id=" + View.EventId.ToString(), ConfigurationManager.AppSettings["BaseUrl"] + "/Images/dj/event.gif", ResourceHelper.Get("LBL_OtherNom"), 15, new string[] { "c" });
        }
        if (View.Upload.Type == FileType.Links)
        {
            HtmlGenericControl body = (HtmlGenericControl)Page.Master.FindControl("_body");
            body.Attributes.Add("onload", "javascript:MaximizedView('" + View.Id.ToString() + "');");
        }
    }
    private void SetJavascript()
    {
        string jScript = "<script type=\"text/javascript\">";
        jScript += "function ShowComments(id) {";
        jScript += "\r\nvotewindow=dhtmlmodal.open('VoteSetBox', 'iframe', 'ShowComment.aspx?id=' + id, 'Votes', 'width=560px,height=410px,center=1,resize=0,scrolling=0')";
        jScript += "\r\nreturn false;";
        jScript += "\r\n}";
        jScript += "var siteurl='" + ConfigurationManager.AppSettings["BaseUrl"] + "'";
        jScript += "\r\n</script>";
        Page.RegisterClientScriptBlock("showComments", jScript);

        jScript = "<script type=\"text/javascript\">";
        jScript += "function MaximizedView(id) {";
        jScript += "var delta=250;";
        jScript += "var width=window.screen.width - delta;";
        jScript += "var height=window.screen.height - delta;";
        jScript += "\r\nvotewindow=dhtmlmodal.open('MaximizedView', 'iframe', 'MaximizeView.aspx?id=' + id, 'MaximizedView', 'width=' + width + 'px,height=' + height + 'px,left=-' + (delta + (delta/2) - 50) + ',top=-' + (delta - (delta/2) + 25) + ',resize=0,scrolling=0')";
        jScript += "\r\nreturn false;";
        jScript += "\r\n}";
        jScript += "var siteurl='" + ConfigurationManager.AppSettings["BaseUrl"] + "'";
        jScript += "\r\n</script>";
        Page.RegisterClientScriptBlock("MaximizedView", jScript);
    }
}
